#include "utils.h"
#include "define.h"

namespace ut {

int fps() {
    static auto start = std::chrono::steady_clock::now();
    auto end = start;
    static int frame_count = 0;
    static int fps = 0;

    end = std::chrono::steady_clock::now();
    frame_count++;
    if (end - start > 1s) {
        fps = frame_count;
        start = end;
        frame_count = 0;
    }
    
    return fps;
}

std::string utf32_to_utf8(const std::u32string &str)
{
    static std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> conv;
    return conv.to_bytes(str);
}


} // namespace ut
